﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using MedicinaMuncii.BL.Contracts;
using MedicinaMuncii.Repository.Contracts;
using MedicinaMuncii.Entities;
using MedicinaMuncii.IoC;

namespace MedicinaMuncii.BL.Implementations
{
    public class EmployeeService : EntityService<Employee>, IEmployeeService
    {
        IEmployeeRepository employeeRepository;

        public EmployeeService()
        {
           employeeRepository = IoCWorker.Resolve<IEmployeeRepository>();
           _repository = employeeRepository;
        }

        public int GetNextAvailableNumber(int companyID)
        {
            int max = employeeRepository
                .GetQuery()
                .Where(e => e.CompanyID == companyID)
                .Max(e => e.Number)
                .GetValueOrDefault();

            return max + 1;
        }
    }
}
